
import dropdown_forlist from "./dropdown_forlist";

let TEMPLATE = `
<el-container>
    <el-header style="text-align: right; font-size: 12px">
        <dropdown_forlist></dropdown_forlist>
    </el-header>
    
    <el-main>
        <h1 v-if="!isloading">{{mid_txt}}</h1>
        <el-table :data="dbinfos" v-loading="isloading" element-loading-text="拼命加载中">
            <el-table-column prop="name" :label="headdescs.name" width="140">
            </el-table-column>
            <el-table-column prop="ver" :label="headdescs.ver" width="140">
            </el-table-column>
            <el-table-column prop="gitee_usr" :label="headdescs.gitee_usr" width="140">
            </el-table-column>
            <el-table-column prop="desc" :label="headdescs.desc">
            </el-table-column>
            <el-table-column prop="uploadtime" :label="headdescs.uploadtime">
            </el-table-column>
        </el-table>
    </el-main>
</el-container>
`
export default {
    name: "list_xpmplugins",
    template: TEMPLATE,
    data: function () {
        return {
            contname: "plugins",
            handleitems: ["点我我什么都不做"],
            dbinfos: [],
            headdescs: {
                name: "插件名称",
                ver: "插件版本",
                gitee_usr: "gitee用户名",
                desc: "插件描述",
                uploadtime: "上传时间"
            },
            isloading: true,
            mid_txt:""
        }
    },

    components: {
        "dropdown_forlist": dropdown_forlist
    },

    mounted: function () {
        axios.get("/api/devcli/get_pageinfo").then(
            (resp) => {
                console.log(resp);
                let issuc = false;
                let ret;
                if (resp.data.hasOwnProperty("data")) {
                    if (resp.data["r"] == 0) {
                        issuc = true;
                        ret = resp.data["data"]
                    }
                }
                if (issuc) {
                    let info;
                    for (const idx in ret) {
                        info = ret[idx];
                        if (info.hasOwnProperty("uploadtime")) {
                            let date = new Date(info["uploadtime"] * 1000);
                            info["uploadtime"] = date.toLocaleDateString();
                        }
                    }
                    this.dbinfos = ret;
                }
                else {
                    this.mid_txt = resp.data["desc"];
                }
                this.isloading = false;
            }
        )
    }
}